package org.truenewx.tnxjee.webmvc.response.reminder.resolver;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.truenewx.tnxjee.core.message.MessageResolver;
import org.truenewx.tnxjee.service.reminder.model.ReminderDescriptor;
import org.truenewx.tnxjee.webmvc.response.reminder.model.ReminderMessage;

import java.util.Locale;

@Component
public class ReminderMessageResolver {

    @Autowired
    private MessageResolver messageResolver;

    public ReminderMessage resolve(ReminderDescriptor reminder, Locale locale) {
        String content = this.messageResolver.resolveMessage(reminder.getCode(), locale, reminder.getArgs());
        return new ReminderMessage(reminder.getType(), content, reminder.getSeconds());
    }

}
